layui.use(['form', 'layer','jquery','tree','util','laydate','upload'], function() {
    $ = layui.jquery;
    var form = layui.form,
    layer = layui.layer,
    upload = layui.upload,
    tree = layui.tree,
    util = layui.util,
    laydate = layui.laydate,
    ctx = $("#baseurl").val();

    //年选择器type: 'year','date','datetime'
    laydate.render({
        elem: '#year'
        ,type: 'year'
    });

    //监听提交
    form.on('submit(edit)', function(data) {
        // data.field.classifyId = JSON.stringify(classifyIds.getValue());
        $.ajax({
            url: ctx+"/choujiang/bach_info/edit",
            data: data.field,
            type: 'post',
            success: function (data) {
                //发异步，把数据提交给php
                layer.alert("增加成功", {icon: 6},function () {
                    //关闭当前frame
                    xadmin.close();
                    // 可以对父窗口进行刷新
                    xadmin.father_reload();
                });
                //return false;
            }
        });
    });

    //头像上传
    var uploadInst = upload.render({
        elem: '#titleimg' //绑定元素
        ,url: ctx+'/file/fileOneAdd/' //上传接口
        ,accept: 'file'
        ,data: {busid:'',type:''}
        ,done: function(res){
            //上传完毕回调
            var data = res.data;
            $("#courseImg").val(data.httpUrl);
        }
        ,error: function(){
            //请求异常回调
        }
    });

});


